﻿namespace Sparkle.MVVM.Messages
{
    public class ResultMessage : IMessage
    {
        public object AssosiatedObject { get; set; }

        public ResultAction<object, object, string, object> MessageResultAction { get; protected set; }

        public ResultMessage(object assosiatedObject, ResultAction<object, object, string, object> messageResultAction)
        {
            AssosiatedObject = assosiatedObject;
            MessageResultAction = messageResultAction;
        }

        public object Process(object sender, string messageName, object attachedObject)
        {
            return MessageResultAction != null ? MessageResultAction(sender, messageName, attachedObject) : null;
        }
    }
}